package hot100;

public class maxSubArray {

    static int max = Integer.MIN_VALUE;

    public int maxSubArray(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            int sum = nums[i];
            max = Math.max(sum, max);
            for (int j = i + 1; j < nums.length; j++) {
                sum = sum + nums[j];
                max = Math.max(sum, max);
            }
        }
        return max;
    }
}
